package com.bsj.power.common.def.entity.cardReport;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bsj.power.common.def.dto.cardReport.BindCardDTO;
import com.bsj.power.common.def.entity.job.WorkPersonnel;
import com.bsj.power.common.def.entity.personnel.Personnel;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @author LiJiaXin
 * @version 1.0.0
 * @description CardReport
 * @time 2024/4/23 19:07
 */
@Data
@TableName(value = "tab_card_report")
@NoArgsConstructor
@AllArgsConstructor
public class CardReport {

    /**
     * 主键id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 设备号
     */
    @TableField("device_name")
    private String deviceName;
    /**
     * 人员类型分类 0:负责人 1:作业人员
     */
    @TableField("classify")
    private Integer classify;

    /**
     * 作业id（同一时间可能派发了多个作业）
     */
    @TableField("job_id")
    private String jobId;

    /**
     * 人员id
     */
    @TableField("personnel_id")
    private Integer personnelId;

    /**
     * 人员信息
     */
    @TableField("personnel_name")
    private String personnelName;

    /**
     * 工号
     */
    @TableField("emp_no")
    private String empNo;

    /**
     * 类型 1绑卡 2退卡
     */
    @TableField("type")
    private Integer type;

    /**
     * 备注
     */
    @TableField("remark")
    private String remark;

    /**
     * 创建时间 || 开始时间
     */
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

//    /**
//     * 修改时间
//     */
//    @TableField("update_time")
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
//    private Date updateTime;
//
//    /**
//     * 绑卡方式 1手动绑卡  2人脸识别自动绑卡
//     */
//    @TableField("bind_way")
//    private Integer bindWay;

    /**
     * 身份证号码
     */
    @TableField("id_card_no")
    private String idCardNo;

    /**
     * 是否重名 1是  2否
     */
    @TableField("is_repetition_name")
    private Integer isRepetitionName;

    /**
     * 结束时间
     */
    @TableField(exist = false)
    private Date endTime;

    public CardReport(BindCardDTO bindCardDTO, Personnel personnel) {
        this.deviceName = bindCardDTO.getDeviceName();
        this.personnelId = personnel.getPersonnelId();
        this.personnelName = personnel.getName();
        this.empNo = personnel.getEmpNo();
        this.type = bindCardDTO.getType();
        this.remark = bindCardDTO.getRemark();
        this.idCardNo = personnel.getIdCardNo();
//        this.bindWay = bindCardDTO.getBindWay();
    }

    public CardReport(String deviceName, Date startTime, Date endTime) {
        this.deviceName = deviceName;
        this.createTime = startTime;
        this.endTime = endTime;
    }

    public CardReport(BindCardDTO bindCardDTO, WorkPersonnel workPersonnel) {
        this.deviceName = bindCardDTO.getDeviceName();
        this.personnelId = workPersonnel.getWorkPersonnelId();
        this.personnelName = workPersonnel.getName();
        this.empNo = workPersonnel.getTemporaryEmpNo();
        this.type = bindCardDTO.getType();
        this.remark = bindCardDTO.getRemark();
        this.idCardNo = workPersonnel.getIdCardNo();
//        this.bindWay = bindCardDTO.getBindWay();
    }

//    public CardReport(Long id, Date updateTime) {
//        this.id = id;
//        this.updateTime = updateTime;
//    }
}
